package com.heima.behavior.service.impl;

import com.heima.behavior.dto.FollowBehaviorDto;
import com.heima.behavior.entity.ApFollowBehavior;
import com.heima.behavior.service.IApFollowBehaviorService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author zsk
 * @create 2022-04-16-22:07
 */
@Service
public class ApFollowBeHaviorServiceImpl implements IApFollowBehaviorService {


    @Autowired
    private MongoTemplate mongoTemplate;

    /**
     * 接受消息
     * @param behaviorDto
     */
    @Override
    public void saveFollow(FollowBehaviorDto behaviorDto) {

        ApFollowBehavior behavior = new ApFollowBehavior();
        BeanUtils.copyProperties(behaviorDto,behavior);
        //补全参数
        behavior.setCreatedTime(new Date());
        //保存
        mongoTemplate.save(behavior);

    }
}
